package org.vaadin.golfscoretracker.ui.components;

import org.vaadin.appfoundation.i18n.Lang;
import org.vaadin.appfoundation.i18n.TranslationUtil;
import org.vaadin.golfscoretracker.data.Hole;

import com.vaadin.data.Item;
import com.vaadin.ui.Component;
import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
import com.vaadin.ui.TextField;

@SuppressWarnings("serial")
public class PlayerFieldFactory extends DefaultFieldFactory {

    @Override
    public Field createField(Item item, Object propertyId, Component uiContext) {
        TextField textField = new TextField();
        textField.setNullRepresentation("");
        textField.setCaption(TranslationUtil.getFieldTranslation(Hole.class,
                (String) propertyId));
        textField.setRequired(true);
        textField.setRequiredError(Lang.getMessage("required validator"));
        textField.setImmediate(true);
        return textField;
    }

}
